# Maintainer: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Larry Hajali <larryhaja [at] gmail [dot] com>

pkgname=megaglest
pkgver=3.13.0
pkgrel=8
pkgdesc="Fork of Glest, a 3D real-time strategy game in a fantastic world"
arch=('loong64' 'x86_64')
url="https://megaglest.org"
license=('GPL3')
depends=('curl' 'megaglest-data' 'xerces-c' 'sdl2' 'libvorbis' 'openal' 'libgl' 'lua51' 'icu' 'ftgl' 'glew'
         'libircclient' 'miniupnpc' 'wxwidgets-gtk3' 'glu' 'libx11' 'libminiupnpc.so')
makedepends=('ftjam' 'cmake' 'mesa')
source=(https://github.com/MegaGlest/megaglest-source/releases/download/${pkgver}/megaglest-source-${pkgver}.tar.xz{,.asc}
        https://github.com/MegaGlest/megaglest-source/commit/789e1cdf.patch
        https://github.com/MegaGlest/megaglest-source/commit/5801b1fa.patch
        https://github.com/MegaGlest/megaglest-source/commit/412b37d0.patch
        https://github.com/MegaGlest/megaglest-source/commit/e09ba53c.patch
        fbd0cfb1.patch)
sha256sums=('09fef67bc6878b1afbb0b403fec9fcf7dc270d500fdc62ed98e5f210e398ccb9'
            'SKIP'
            'dbb8e5b6953bd2f86ecbb9c60ac00c0c25299f2738fbdc39996adaed844cd6ed'
            'f3e12b58b39f97109d5d077b7ea7b31a5f21355c55f837584aa2ea62030889c6'
            '2acda6052ccedd7d0f77067c9b5f01a3a1c5f2ed6b46dc962b18dfdac9515906'
            '1a01f115bc9653c151fed83b1e6c0b71a4508083777158934be975f8b5b089ff'
            '5dc0096ea581ca9436b2de528f913ac99de7a1a5d00bc7e8d52117298fd1eeb5')
validpgpkeys=('0DA321A44B30EF477E9A6DB8DE45EB9E71EEB59B')

prepare() {
  # Fix build with wxWidgets 3.2
  cd $pkgname-$pkgver
  patch -p1 < ../789e1cdf.patch
  patch -p1 < ../5801b1fa.patch
  patch -p1 < ../412b37d0.patch
  patch -p1 < ../e09ba53c.patch
  patch -p1 < ../fbd0cfb1.patch
}

build() {
  cd megaglest-${pkgver}

  [[ -d build ]] && rm -r build
  mkdir build && cd build

  cmake .. \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_C_FLAGS="${CXXFLAGS} -fcommon" \
    -DCMAKE_CXX_FLAGS="-lX11 ${CXXFLAGS} -fcommon" \
    -DWANT_GIT_STAMP=0
  make VERBOSE=1
}

package() {
  cd megaglest-${pkgver}/build

  make DESTDIR="$pkgdir" install
}

# vim: sw=2:ts=2 et:
